UE.FormDesignBaseUrl = 'form-design'; 

mini.parse();


function addListenerWithControl(t, evt,thePlugins,name,popup){
	 evt = evt || window.event;  
     var el = evt.target || evt.srcElement;  
     var miniPlugins = el.getAttribute('plugins');  
     if ( /input/ig.test( el.tagName ) && miniPlugins==thePlugins) {  
         var html = popup.formatHtml(  
             '<nobr>'+name+': <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>' );  
         if ( html ) {  
             popup.getDom( 'content' ).innerHTML = html;  
             popup.anchorEl = el;  
             popup.showAnchor( popup.anchorEl );  
         } else {  
             popup.hide();  
         }  
     }  
}

function save(callBack,projectName,form){
	mini.get("htmlCode").setValue(designer.getContent());
	var json = mini.encode(GetDataTableDefine(form));
		mini.mask({
	        el: document.body,
	        cls: 'mini-mask-loading',
	        html: '正在保存信息...'
	    }); 
		$.ajax({
			url : projectName+"/TableDefineAdmin/saveTableDefine",
			type : 'post',
			contentType : "application/json; charset=utf-8",
			dataType : 'json',
			data : json,
			cache : false,
			success : function(data) {
				mini.unmask();
				if (data.status == '1') {
					form.setData(data.result);
					mini.alert(data.message, "" , function() {
						  if (typeof callback === "function"){
							  callBack(); 
					        }
					});
				} else if(data.status == '0') {
					mini.alert(data.message);
				} else {
					mini.alert("发生错误!");
				}
			},
			error : function(jqXHR, textStatus, errorThrown) {
			    mini.unmask();
				mini.alert(jqXHR.responseText);
			}
		});
 }
 
 function GetDataTableDefine(form){
		var o = form.getData();
		return o;
	}

 
 function generateTable(callBack,projectName,form){
		mini.get("htmlCode").setValue(designer.getContent());
		var data = GetDataTableDefine(form);
		if(!(data.dymcformId || data.tableName)){
			mini.alert("请先进行保存");
			return false;
		}
		var json = mini.encode(data);
		
			mini.mask({
		        el: document.body,
		        cls: 'mini-mask-loading',
		        html: '正在保存信息...'
		    }); 
			$.ajax({
				url : projectName+"/TableDefineAdmin/generateTable",
				type : 'post',
				contentType : "application/json; charset=utf-8",
				dataType : 'json',
				data : json,
				cache : false,
				success : function(data) {
					mini.unmask();
					if (data.status == '1') {
						mini.get("isDeployed").setValue("1");
						mini.alert(data.message, "" , function() {
							  if (typeof callback === "function"){
								  callBack(); 
						        }
						});
					} else if(data.status == '0') {
						mini.alert(data.message);
					} else {
						mini.alert("发生错误!");
					}
				},
				error : function(jqXHR, textStatus, errorThrown) {
				    mini.unmask();
					mini.alert(jqXHR.responseText);
				}
			});
	 }
	 